import 'package:flutter/material.dart';
import 'package:kq_flutter_core_widget/utils/kq_screen_util.dart';

import '../../config/kq_global.dart';
import '../../resources/images.dart';

/// 印章控件
class KqPrintImage extends StatelessWidget {
  /// 印章类型，使用[KqPrintType]
  final KqPrintType printType;

  /// 是否中文，因为有英文图标，所以要传语言，中文用中文图片，其他语言用英文图标。
  final bool isChinese;

  /// 自定义宽度，默认44.r
  final double? width;
  /// 自定义高度，默认44.r
  final double? height;

  const KqPrintImage({
    Key? key,
    required this.printType,
    required this.isChinese,
    this.width,
    this.height,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    String img = Images.commonIcHege;
    if (printType == KqPrintType.qualified) {
      img = Images.commonIcHege;
    } else if (printType == KqPrintType.giveStep) {
      img = Images.commonIcRangbu;
    } else if (printType == KqPrintType.unqualified) {
      img = Images.commonIcBuhege;
    } else if (printType == KqPrintType.waste) {
      img = isChinese ? Images.commonIcZuofei : Images.commonIcZuofeiEn;
    } else if (printType == KqPrintType.expired) {
      img =
          isChinese ? Images.commonIcShixiao : Images.commonIcShixiaoEn;
    } else if (printType == KqPrintType.withdraw) {
      img = isChinese ? Images.commonIcChexiao : Images.commonIcChexiaoEn;
    } else if (printType == KqPrintType.hasRemake) {
      img = isChinese ? Images.commonIcFanxiu : Images.commonIcFanxiuEn;
    }
    return Image.asset(img,
        width: width ?? 64.r,
        height: height ?? 64.r,
        fit: BoxFit.fill,
        package: KqGlobal.packageName);
  }
}

enum KqPrintType {
  /// 合格
  qualified,

  /// 让步
  giveStep,

  /// 不合格
  unqualified,

  /// 作废
  waste,

  /// 失效
  expired,

  /// 撤销,退回
  withdraw,

  /// 已返修
  hasRemake,
}
